package com.bookcloud.java21.chapter6.抽象类69;

public class Rectangle extends Shape {
  private double width;
  private double height;

  public Rectangle(String color, double width, double height) {
    super(color);
    this.width = width;
    this.height = height;
  }

  // 子类自己的方法
  public double getWidth() {
    return width;
  }

  public double getHeight() {
    return height;
  }

  public void setDimensions(double width, double height) {
    this.width = width;
    this.height = height;
  }

  // 实现抽象方法
  @Override
  public double getArea() {
    return width * height;
  }

  @Override
  public double getPerimeter() {
    return 2 * (width + height);
  }
}
